package com.group.www.service.impl;

import com.group.www.dao.impl.OrderinfoDao;
import com.group.www.interfaces.IorderInfo_q;
import com.group.www.pojo.MessageInfo;
import com.group.www.pojo.OrderInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@com.alibaba.dubbo.config.annotation.Service
@Service
public class SimpleOrderinfo_qService implements IorderInfo_q{

    @Autowired
    private OrderinfoDao orderinfoDao;

    @Override
    public List<OrderInfo> queryorderId(Integer userId, Integer osId) {
        return orderinfoDao.queryorderId(userId,osId);
    }

    @Override
    public List<OrderInfo> queryorderIdbyuserId(Integer userId) {
        return orderinfoDao.queryorderIdbyuserId(userId);
    }

    @Override
    public boolean add(OrderInfo orderInfo) {
        orderinfoDao.save(orderInfo);
        return true;
    }

    @Override
    public boolean delete(Integer userId, Integer orderId) {
        orderinfoDao.delete(userId,orderId);
        return true;
    }

    @Override
    public boolean update(OrderInfo orderinfo) {
        this.orderinfoDao.update(orderinfo);
        return true;
    }

    @Override
    public boolean add(Object entity) {
        if(entity instanceof OrderInfo){
            return add((MessageInfo)entity);
        }
        return false;
    }

    @Override
    public boolean update(Object entity) {
        if(entity instanceof OrderInfo){
            return update((OrderInfo)entity);
        }
        return false;
    }

    @Override
    public List query() {
        return this.orderinfoDao.query();
    }

    @Override
    public boolean delete(Object entity) {
        if(entity instanceof OrderInfo){
            MessageInfo msgInfo = (MessageInfo) entity;
            orderinfoDao.deleteByOrderId(msgInfo.getMessageid());
            return  true;
        }
        return false;
    }
}
